"use client";
import React, { useCallback } from "react";

const ServerAction = () => {
  const onCreate = useCallback(async (formData) => {
    const body = Object.fromEntries(formData);
    console.log(body, 88);
    await fetch("/api/blog", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
      body: JSON.stringify(body),
    });
  }, []);

  const onDelete = useCallback((formData) => {}, []);
  return (
    <div>
      <form action={onCreate}>
        <input type="text" placeholder="title" name="title" />
        <input type="text" placeholder="body" name="body" />
        <input type="text" placeholder="img" name="img" />
        <input type="text" placeholder="userId" name="userId" />
        <button>create</button>
      </form>

      <form action={onDelete}>
        <input type="text" placeholder="id" name="id" />
        <button>delete</button>
      </form>
    </div>
  );
};

export default ServerAction;
